import gl
from PyQt5 import QtCore


def get_text_input(txt):
    gl.g_driver_obj.get_input.connect(gl.g_recv_obj.recv_input)
    gl.g_recv_obj.sgn.connect(gl.g_driver_obj.on_get_text_input)
    loop=QtCore.QEventLoop()
    gl.g_driver_obj.get_input.connect(loop.quit)
    gl.g_recv_obj.sgn.emit(txt)
    loop.exec()
    gl.g_driver_obj.get_input.disconnect(gl.g_recv_obj.recv_input)
    gl.g_recv_obj.sgn.disconnect(gl.g_driver_obj.on_get_text_input)
    gl.g_driver_obj.get_input.disconnect(loop.quit)
    return gl.g_recv_obj.get_input()


def get_line_input(txt):
    gl.g_driver_obj.get_input.connect(gl.g_recv_obj.recv_input)
    gl.g_recv_obj.sgn.connect(gl.g_driver_obj.on_get_line_input)
    loop = QtCore.QEventLoop()
    gl.g_driver_obj.get_input.connect(loop.quit)
    gl.g_recv_obj.sgn.emit(txt)
    loop.exec()
    gl.g_driver_obj.get_input.disconnect(gl.g_recv_obj.recv_input)
    gl.g_recv_obj.sgn.disconnect(gl.g_driver_obj.on_get_line_input)
    gl.g_driver_obj.get_input.disconnect(loop.quit)
    return gl.g_recv_obj.get_input()
